// (C) Andrea Giammarchi
bytefw={COMPATIBILITY:"ie5",REALCOMPATIBILITY:"ie5",DEPENDENCIES:{core:["Array","Boolean","Date","Function","Node","Number","Object","String","Window"]},PROTOTYPED:{},browser:function(){var tmp=navigator.userAgent.toLowerCase();switch(true){case bytefw.core.bool.$(window.opera):tmp="opera".concat(opera.version());break;case/\bwebkit\b/.test(tmp):tmp="safari";break;case/\bkhtml\b/.test(tmp):tmp="khtml";break;case/\bgecko\b/.test(tmp):tmp="gecko";break;case/\bmsie\b\s*(\d+\.\d+)/.test(tmp):tmp.replace(/\bMSIE\b\s*(\d+\.\d+)/,function(a,b){tmp="ie".concat(b)});break;default:tmp="undefined";break;};return tmp},exec:window.execScript||function(code){return eval.call(window,code)},extend:function(namespace,func,init){var path=["bytefw"].concat(namespace.split(".")),u;if(func.constructor===Function){path[path.length]=(func.name=bytefw.type(func));if(window[func.name]&&window[func.name]===func)window[func.name]=u;};eval(path.join(".").concat("=func"));if(init){bytefw.init();init(func);};},flash:function(){var result;if(((result=navigator.plugins)&&result.length&&(result=result['Shockwave Flash'])&&(result=result.description))||((result=navigator.mimeTypes)&&result.length&&(result=result['application/x-shockwave-flash'])&&(result=result.enabledPlugin)&&(result=result.description)))result=parseInt(result.replace(/.+(\d+)\..+$/,"$1"));else if(window.ActiveXObject)for(var i=4;i;i++){try{new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+i);result=i}catch(e){i=-1}};return result||0;},init:function(callback){for(var key in bytefw.core.window){if(!window[key])window[key]=bytefw.core._addprototype("window",key,bytefw.core.window[key]);};bytefw.core.window.XMLHttpRequest.name="[XMLHttpRequest]";bytefw.core.window.XMLHttpRequest.toString=function(){return this.name};bytefw.core._15([]);bytefw.core._15(new Date);bytefw.core._15(document);bytefw.core._15(1);bytefw.core._15(function(){});bytefw.core._15("");if(callback)callback.call(bytefw);},lang:function(){return navigator.language||navigator.browserLanguage},is_a:function(tmp,type){var result=false;switch(type){case"mail":result=/^([a-z0-9]+[\._\-]?){1,3}([a-z0-9])*\@([a-z0-9]+[\.\-]?){1,3}([a-z0-9])*\.[a-z]{2,6}$/i.test(tmp);break;case"uri":result=/^(\w{3,}:\/\/|w{3}[0-9]*\..{3,}\..{2,})$/i.test(tmp);break;default:result=bytefw.type(tmp)===type;break;};return result;},rand:function(min,max){return Math.floor(Math.random()*(max+1-min))+min;},range:function(min,max){var result,t=true;if(!max){max=min;min=0;};result=new Array(max);while(min<max)result[min++]=t;return result;},type:function(tmp){var result;if(tmp===null)result="null";else if(tmp===result)result="undefined";else{result=bytefw.core.func.$name(tmp);if(result==="anonymous"&&tmp.constructor&&tmp.constructor.name)result=tmp.constructor.name;else if(result==="Object"&&tmp.constructor.prototype){for(result in this){if(typeof(this[result])==="function"&&tmp instanceof this[result]){result=bytefw.type(this[result]);break;}}}};return result;},core:{_15:function(type){function _15(parent,tmp,constructor){for(var key in tmp){if(!/prototype/.test(key)&&key.charAt(0)!=="$"&&!constructor.prototype[key])constructor.prototype[key]=bytefw.core._addprototype(parent,key,tmp[key]);}};switch(type.constructor){case Array:_15("Array",bytefw.core.array,Array);break;case Date:_15("Date",bytefw.core.date,Date);break;case Function:_15("Function",bytefw.core.func,Function);break;case Number:_15("Number",bytefw.core.number,Number);break;case String:_15("String",bytefw.core.string,String);if("aa".replace(/\w/g,function(){return"".concat(arguments[1]," ")})!=="0 1 ")String.prototype.replace=bytefw.core._addprototype("String","replace",bytefw.core.string.replace(""));break;default:type=bytefw.core.node.$(type);break;};return type},_addprototype:function(constructor,tmp,callback){var name=constructor.concat(".",tmp);if(!bytefw.PROTOTYPED[name]){bytefw.PROTOTYPED[name]=callback;callback.name=tmp;callback.toString=new Function("","".concat("return 'function ",tmp,"(){\\n    [native code]\\n}'"));};return callback}},utils:{},comps:{}};bytefw.extend("core.array",{$:function(a){for(var i=0,j=a.length,t=new Array(j);i<j;i++)t[i]=a[i];return t},$rgb2hex:function(color){return"#".concat(color.map(function(c){return bytefw.core.string.$pad(c.toString(16),2,"0",0)}).join(""))},$uniq:function(){var tmp=[],i=0,j=0,k=this.length;tmp.check=function(value){var i=j,result=true;while(i--&&result)result=!(this[i]===value);if(result)this[j++]=value;};while(i<k)tmp.check(this[i++]);return tmp;},every:function(callback){for(var i=0,j=this.length,result=true,self=arguments[1];i<j&&result;i++)result=callback.call(self,this[i],i,this);return result},filter:function(callback){for(var i=0,j=this.length,k=0,result=[],self=arguments[1],u;i<j;i++){if(this[i]!==u&&callback.call(self,this[i],i,this))result[k++]=this[i];};return result},forEach:function(callback){for(var i=0,j=this.length,self=arguments[1],u;i<j;i++){if(this[i]!==u)callback.call(self,this[i],i,this);}},indexOf:function(tmp,i){var j=this.length,k=bytefw.core.number.$(i);if(k>-1){while(k<j){if(this[k++]===tmp){k=k-1+j;j=k-j;}}}else j=this.indexOf(tmp,j+k);return j!==this.length?j:-1;},lastIndexOf:function(tmp,i){var l=this.length,j=-1,k=bytefw.core.number.$(i)||l;if(k>-1){do{if(this[k--]===tmp){j=k+1;k=0;}}while(k>0);}else if(k>-l)j=this.lastIndexOf(tmp,l+k);return j},map:function(callback){for(var i=0,j=this.length,result=new Array(j),self=arguments[1],u;i<j;i++){if(this[i]!==u)result[i]=callback.call(self,this[i],i,this);};return result},pop:function(){var i=this.length-1,result=this[i];if(i>-1)this.length=i;return result},push:function(){var self=this,i=self.length;[].forEach.call(arguments,function(tmp){self[i++]=tmp});return i},shift:function(){this.reverse();var result=this.pop();this.reverse();return result},some:function(callback){for(var i=0,j=this.length,result=false,self=arguments[1];i<j&&!result;i++)result=callback.call(self,this[i],i,this);return result},splice:function(){var a=bytefw.core.array.$(arguments),tmp=[],i=0,j=this.length,k=0,l=arguments.length,result;switch(l){case 0:break;case 1:a[1]=!l++||this.length-bytefw.core.number.$(a[0]);default:a[0]=bytefw.core.number.$(a[0]);a[1]=bytefw.core.number.$(a[1]);k=a[0]+a[1];for(;i<j;i++){if(i<a[0]||i>=k){if(i===k&&l>2){for(i=2;i<l;i++)tmp.push(a[i]);i=k;};tmp.push(this[i]);}else{if(!result)result=[];result.push(this[i]);};};for(i=0,j=tmp.length;i<j;i++)this[i]=tmp[i];this.length=i;break;};return result},unshift:function(){var i=arguments.length;this.reverse();while(i--)this.push(arguments[i]);return this.reverse().length}});bytefw.extend("core.bool",{$:function(t){return!!t}});bytefw.extend("core.date",{getYear:function(){return this.getFullYear()-1900}});bytefw.extend("core.func",{$name:function(func){return"".concat(func).replace(/^\s*\(?\s*function\s*([^\(]*)\s*\([^\x00]+$/,"$1")},apply:function(self,tmp){for(var i=0,j=tmp.length,result,value=[];i<j;i++)value[i]="tmp[".concat(i,"]");if(!self)result=eval("this(".concat(value.join(","),")"));else{self[j=bytefw.core.object.$method(self)]=this;result=eval("self[j](".concat(value.join(","),")"));delete self[j];};return result;},call:function(){var tmp=bytefw.core.array.$(arguments);return this.apply(tmp.shift(),tmp);}});bytefw.extend("core.node",{$:function(type){var b=bytefw.browser(),m="getElementsByTagName";if(/^ie/.test(b)&&parseInt(b.substring(2))<6){function $(old){return function(search){var result=[],f=""+arguments.callee;if(search==="*")nested(this,result,f);else{for(var nodes=old(search),i=0,j=nodes.length;i<j;i++){if(""+nodes[i][m]!==f)nodes[i][m]=$(nodes[i][m]);result[i]=nodes[i];}};result.item=function(i){return this[i]};return result;};};function nested(parent,result,f){for(var nodes=parent.childNodes,i=0,j=nodes.length;i<j;i++){if(nodes[i].nodeType!==3){if(""+nodes[i][m]!==f)nodes[i][m]=$(nodes[i][m]);result[result.length]=nodes[i];if(nodes[i].hasChildNodes())nested(nodes[i],result,f);}};};type[m]=bytefw.core._addprototype("document",m,$(type[m]));};return type;},$call:function(callback,element,evt){var b=bytefw.browser(),result,u;if(!/ie/.test(b)||parseFloat(b.substring(2))>5.4)result=callback.call(element,evt);else{b=bytefw.core.object.$method(element);element[b]=callback;result=element[b](evt);element[b]=u;};return result;},$event:function(evt){var event=window.event;if(!evt&&event){evt={};for(var key in event){try{evt[key]=event[key]}catch(e){}};evt.charCode=(evt.type=="keypress")?evt.keyCode:0;evt.eventPhase=evt.eventPhase||2;evt.isChar=evt.isChar||(evt.charCode>0);evt.keyCode=evt.keyCode||(event.which?event.which:event.charCode);evt.preventDefault=evt.preventDefault||function(){event.returnValue=false};evt.stopPropagation=evt.stopPropagation||function(){event.cancelBubble=true};evt.target=evt.target||event.srcElement;evt.time=evt.time||(new Date).getTime();if(!evt.relatedTarget){switch(evt.type){case"mouseout":evt.relatedTarget=evt.toElement;break;case"mouseover":evt.relatedTarget=evt.fromElement;break;}};evt.pageX=evt.clientX+(document.body.scrollLeft||document.documentElement.scrollLeft);evt.pageY=evt.clientY+(document.body.scrollTop||document.documentElement.scrollTop);};return evt;},$position:function(element){var position={x:element.offsetLeft,left:0,y:element.offsetTop,top:0};while(element=element.offsetParent){position.x+=element.offsetLeft;position.y+=element.offsetTop;};position.left=position.x;position.top=position.y;return position;},$scroll:function(element){function scroll(p,s){return(e?e[p]:window[s]||d.body[p])||0};var d=document,e=d.documentElement,result=null;switch(element){case window:case d:case d.body:case e:result={x:scroll("scrollLeft","pageXOffset"),y:scroll("scrollTop","pageYOffset")};break;default:result={x:element.scrollLeft,y:element.scrollTop};break;};result.left=result.x;result.top=result.y;return result;},$size:function(element){return{width:element.offsetWidth,height:element.offsetHeight};}});bytefw.extend("core.number",{$:function(i,t,b){if(!i||i.constructor!==Number)i=t?parseFloat(i):parseInt(i,b||10);return!isNaN(i)?i:0;},toExponential:function(fracDigits){var f=this,exp=Math.floor(Math.log(Math.abs(f))/Math.LN10+0.000001),n=typeof(fracDigits)==="undefined"?Math.abs(f)*Math.pow(10,0-exp-1):Math.round(Math.abs(f)*Math.pow(10,fracDigits-exp)),s=bytefw.core.string.$(n).replace(/(\d)/,"$1.");s+=(exp>=0?'e+':'e')+exp;if(f<0)s='-'+s;return s;},toFixed:function(max){var result=Math.pow(10,max=bytefw.core.number.$(max)),tmp=new Array(2);result=bytefw.core.string.$(Math.round(this*result)/result);if(max>0){tmp=result.split(".");tmp[1]=tmp[1]?bytefw.core.string.$pad(tmp[1],max,"0",1):bytefw.core.string.$repeat("0",max);result=tmp.join(".");};return result}});bytefw.extend("core.object",{$method:function(obj){var m,u;do{m="__".concat(Math.random()*1234567).replace(/\./,"_")}while(obj[m]!==u);return m;},$for:function(obj,callback){for(var key in obj){if(obj.constructor.prototype[key]!==obj[key])callback(key,obj[key]);}}});bytefw.extend("core.string",{$:function(t){return"".concat(t)},$camel:function(s){return s.toLowerCase().replace(/\-(\w)/g,function(a,c){return c.toUpperCase()});},$ltrim:function(s){return bytefw.core.string.$(s||"").replace(/^(\s+|\x00+|\x0B+)/,"");},$hex2rgb:function(color){var c=color.replace(/#/,"").split(""),rgb=function(i,j){return parseInt(c[i].concat(c[j]),16)};if(c.length<6)c=[c[0],c[0],c[1],c[1],c[2],c[2]];return[rgb(0,1),rgb(2,3),rgb(4,5)]},$parse:function(str,obj){for(var arr,exec=bytefw.exec,tmp=bytefw.core.string.$(str||"").replace(/&amp;/g,"&").split("&"),i=0,j=tmp.length;i<j;i++){arr=tmp[i].split("=");if(arr[1]){try{arr[1]=decodeURIComponent(arr[1])}catch(e){arr[1]=unescape(arr[1])}}else arr[1]="";if(/\[\]$/.test(arr[0])){arr[0]=arr[0].substr(0,arr[0].length-2);if(obj){if(!obj[arr[0]])obj[arr[0]]=[];obj[arr[0]].push(arr[1]);}else if(eval("typeof($".concat(arr[0],")==='undefined'")))exec("$".concat(arr[0],"=[arr[1]]"));else exec("$".concat(arr[0],".push(arr[1])"));}else if(obj)obj[arr[0]]=arr[1];else exec("$".concat(arr[0],"=arr[1]"));};return obj?obj:null;},$pad:function(input,length,pad_string,pad_type){input=bytefw.core.string.$(input||" ");length=bytefw.core.number.$(length);var tmp=input.length;if(tmp<length){pad_string=bytefw.core.string.$(pad_string||" ");pad_type=!pad_type&&pad_type!==0?1:bytefw.core.number.$(pad_type);switch(pad_type){case 0:case 1:while(pad_string.length+tmp<length)pad_string+=pad_string;pad_string=pad_string.substr(0,length-tmp);input=pad_type===0?pad_string.concat(input):input.concat(pad_string);break;case 2:input=bytefw.core.string.$pad(bytefw.core.string.$pad(input,Math.ceil(tmp+(length-tmp)/2),pad_string,1),length,pad_string,0);break;};};return input;},$repeat:function(str,tmp){str=bytefw.core.string.$(str||" ");tmp=bytefw.core.number.$(tmp);for(var i=0,result=new Array(tmp);i<tmp;i++)result[i]=str;return result.join("");},$rtrim:function(s){return bytefw.core.string.$(s||"").replace(/(\s+|\x00+|\x0B+)$/,"");},$sprintf:function(){var tmp=bytefw.core.array.$(arguments);return bytefw.core.string.$vsprintf(tmp.shift(),tmp);},$vsprintf:function(format,args){function fs(c){var m=re().exec(c);switch(m[5]){case"b":case"c":case"d":case"u":case"o":case"x":case"X":args[i]=num(args[i]);break;case"e":case"f":case"F":args[i]=num(args[i],true);break;};switch(true){case c.length===2:switch(m[5]){case"b":c=args[i].toString(2);break;case"c":c=String.fromCharCode(args[i]);break;case"d":c=args[i].toString();break;case"e":c=args[i].toExponential(5);break;case"f":case"F":c=args[i].toFixed(6);break;case"o":c=args[i].toString(8);break;case"s":c=str(args[i],"");break;case"u":if(args[i]<0){args[i]=4294967296-(Math.abs(args[i])%4294967296);if(args[i]===4294967296)args[i]=0;};c=args[i];break;case"x":case"X":c=args[i].toString(16);c=m[5]==="x"?c.toLowerCase():c.toUpperCase();break;};++i;break;case c.substr(0,2)!=="%%":if(!m[2])m[2]=" ";else if(m[2]&&m[2].length>1)m[2]=m[2].substring(1);switch(m[5]){case"d":c=nf(args[i].toString(),m);break;case"e":c=pad(args[i].toExponential(num(m[4].substring(1))-1),num(m[3]),m[2],m[1]==="-"?1:0);break;case"f":case"F":c=nf(args[i].toFixed(num(m[4].substring(1))),m);break;case"s":c=args[i].toString();if(m[4])c=c.toString().substr(0,num(m[4].substring(1)));c=pad(c,num(m[3]),m[2],m[1]==="-"?1:0);break;case"b":case"c":case"o":case"u":case"x":case"X":c=pad(vsprintf("%".concat(m[5]),[args[i]]),num(m[3]),m[2],m[1]==="-"?1:0);break;};++i;break;default:c=c.substring(1);break;};return c};function nf(c,m){if(m[2]&&m[2].length>1)m[2]=m[2].substring(1);switch(m[1]){case"+":if(m[2]&&m[3])c=pad(c,num(m[3]),m[2],0);if(args[i]>=0)c="+".concat(c);else if(m[2]==="0")c="-".concat(c.replace(/\-/,""));break;case"-":if(m[2]!=="0"&&m[3])c=pad(c,num(m[3]),m[2],1);if(args[i]>=0)c=c.replace(/\-/,"");break;default:if(m[2]&&m[3])c=pad(c,num(m[3]),m[2],0);break;};return c};function re(){return new RegExp("%?%(\\+|\\-)?('.| |0)?([0-9]+)?(\\.[0-9]+)?(b|c|d|e|u|f|F|o|s|x|X)","g")};var i=0,j=args.length,num=bytefw.core.number.$,str=bytefw.core.string.$,pad=bytefw.core.string.$pad,vsprintf=arguments.callee;return format.replace(re(),fs);},$trim:function(s){return bytefw.core.string.$(s||"").replace(/^(\s+|\x00+|\x0B+)|(\s+|\x00+|\x0B+)$/,"");},lastIndexOf:function(tmp,i){var self=this.split(""),result;tmp=bytefw.core.string.$(tmp).split("");result=self.reverse().join("").indexOf(tmp.reverse().join(""),bytefw.core.number.$(i));return result<0?result:this.length-tmp.length-result;},replace:function(type){return(function(replace){return function(reg,type){var result;this.replace=replace;if(type.constructor!==Function)result=this.replace(reg,bytefw.core.string.$(type));else{var loop=true,i=0,end=0,arr=[],tmp=[];result=this.toString();while(loop){if(arr=reg.exec(result)){tmp.push(result.substr(0,arr.index),arr.concat([this.indexOf(arr[0],end+arr.index),this]));result=result.substring(end=arr[0].length+arr.index);}else end=0;if(!end)loop=false;};tmp.push(result.substring(end));for(i=1,end=tmp.length;i<end;i+=2)tmp[i]=type.apply(null,tmp[i]);result=tmp.join("");};this.replace=arguments.callee;return result;};})(type.replace);}});bytefw.extend("core.window",{$size:function(){var size;if(typeof(window.innerWidth)==='number')size={width:window.innerWidth,height:window.innerHeight};else if((size=document.documentElement)&&(size.clientWidth||size.clientHeight))size={width:size.clientWidth,height:size.clientHeight};else if((size=document.body)&&(size.clientWidth||size.clientHeight))size={width:size.clientWidth,height:size.clientHeight};else size={width:0,height:0};return size;},decodeURIComponent:function(str){return bytefw.core.string.$(str).replace(/(%F[0-9A-F]%E[0-9A-F]%[A-B][0-9A-F]%[8-9A-B][0-9A-F])|(%E[0-9A-F]%[A-B][0-9A-F]%[8-9A-B][0-9A-F])|(%[C-D][0-9A-F]%[8-9A-B][0-9A-F])|(%[0-9A-F]{2})/g,function(a,b,c,d,e){return String.fromCharCode(e?parseInt(e.substr(1,2),16):d?((parseInt(d.substr(1,2),16)-0xC0)<<6)+(parseInt(d.substr(4,2),16)-0x80):c?((parseInt(c.substr(1,2),16)-0xE0)<<12)+((parseInt(c.substr(4,2),16)-0x80)<<6)+(parseInt(c.substr(7,2),16)-0x80):((parseInt(b.substr(1,2),16)-0xF0)<<18)+((parseInt(b.substr(4,2),16)-0x80)<<12)+((parseInt(b.substr(7,2),16)-0x80)<<6)+(parseInt(b.substr(10,2),16)-0x80))});},encodeURIComponent:function(str){function charCodeAt(i,len){return bytefw.core.string.$pad(i.toString(16).toUpperCase(),len||2,"0",0)};function encodeURIComponent(a,b){var i=b.charCodeAt(0),tmp=[];if(i<128)tmp.push(i);else if(i<2048)tmp.push(0xC0+(i>>6),0x80+(i&0x3F));else if(i<65536)tmp.push(0xE0+(i>>12),0x80+(i>>6&0x3F),0x80+(i&0x3F));else tmp.push(0xF0+(i>>18),0x80+(i>>12&0x3F),0x80+(i>>6&0x3F),0x80+(i&0x3F));return"%".concat(tmp.map(charCodeAt).join("%"));};function replace(tmp){switch(tmp.length===1?tmp.charCodeAt(0):0){case 8:tmp="\\b";break;case 10:tmp="\\n";break;case 11:tmp="\\v";break;case 12:tmp="\\f";break;case 13:tmp="\\r";break;case 34:tmp="\\\"";break;case 92:tmp="\\\\";break;default:tmp=tmp.replace(/([\x00-\x07]|[\x0E-\x1F]|[\x7F-\xFF])/g,function(a,b){return"\\x".concat(charCodeAt(b.charCodeAt(0)))}).replace(/([\u0100-\uFFFF])/g,function(a,b){return"\\u".concat(charCodeAt(b.charCodeAt(0),4))});break;};return tmp;};return bytefw.core.string.$(str).replace(/([\x00-\x20]|[\x25|\x3C|\x3E|\x5B|\x5D|\x5E|\x60|\x7F]|[\x7B-\x7D]|[\x80-\uFFFF])/g,encodeURIComponent).replace(/([\x23|\x24|\x26|\x2B|\x2C|\x2F|\x3A|\x3B|\x3D|\x3F|\x40])/g,function(a,b){return"%".concat(charCodeAt(b.charCodeAt(0)))}).replace(/"/g,"%22").replace(/\\/g,"%5C");},XMLHttpRequest:function(){this.abort=function(){self.readyState=4;request=false;xhr.abort()};this.getAllResponseHeaders=function(){var h=[];try{h=xhr.getAllResponseHeaders()}catch(e){};return h};this.getResponseHeader=function(type){var h=null;try{h=xhr.getResponseHeader(type)}catch(e){};return h};this.open=function(method,page,async,user,pass){sync.async=async;sync(this,xhr.open(method,page,async,user,pass)||lastChange)};this.send=function(param){var self=this,last=lastChange,refresh=function(){last=sync(self,last);if(xhr.readyState===4||!request)clearInterval(n);return arguments.callee;};request=true;if(sync.async)n=setInterval(refresh(),1);xhr.send(param);if(!sync.async)sync(self,lastChange);};this.setRequestHeader=function(type,param){xhr.setRequestHeader(type,param)};this.onreadystatechange=null;this.readyState=0;this.responseText="";this.responseXML=null;this.status=0;this.statusText="";this.toString=function(){return"[object XMLHttpRequest]"};function init(){if(window.ActiveXObject){["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0"].forEach(function(x){if(!xhr)try{xhr=new ActiveXObject(x)}catch(e){};});xhr.onreadystatechange=function(){lastChange++}}};function sync(self,change){syncParams.forEach(function(p){if(typeof(xhr[p])!=="unknown"&&self[p]!==xhr[p])self[p]=xhr[p];});if(self.onreadystatechange&&lastChange!==change)self.onreadystatechange();return lastChange;};var xhr=null,n=7,request=false,lastChange=0,syncParams=["readyState","responseText","responseXML","status","statusText"];init(xhr);}});